package com.pft.web.view.baseui;

import android.app.ProgressDialog;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.view.Window;

public class BaseActivity
        extends FragmentActivity {
    protected FragmentManager mFragmentManager;

    protected void onCreate(Bundle paramBundle) {
        this.mFragmentManager = getSupportFragmentManager();
//        requestWindowFeature(1);
//        View localView = ((ViewGroup) findViewById(16908290)).getChildAt(0);
//        if ((localView != null) && (Build.VERSION.SDK_INT >= 14)) {
//            localView.setFitsSystemWindows(true);
//        }
        super.onCreate(paramBundle);
    }

    protected void onDestroy() {
        super.onDestroy();
    }

    protected void onPause() {
        super.onPause();
    }

    protected void onResume() {
        super.onResume();
    }

    protected void onStart() {
        super.onStart();
    }

    protected void setStatusBar(int paramInt) {
        if (Build.VERSION.SDK_INT >= 21) {
            Window localWindow = getWindow();
            localWindow.addFlags(Integer.MIN_VALUE);
            localWindow.setStatusBarColor(ContextCompat.getColor(this, paramInt));
        }
    }


    private ProgressDialog progressDialog;

    public void showLoading() {
        showLoading("数据加载中...");
    }


    public ProgressDialog showLoading(String msg) {

        if (progressDialog == null) {
            progressDialog = ProgressDialog.show(this, null, msg, false, false);
        } else {
            progressDialog.setMessage(msg);
            progressDialog.show();
        }
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(false);
        return progressDialog;
    }

    public void dismissLoading() {
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
            progressDialog = null;
        }
    }

}
